<!DOCTYPE html>

<html lang="en">
  <head>
    
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>视图助手 (Tags)（View Helpers (Tags)） &mdash; Phalcon 3.0.1 文档</title>
    <meta name="keywords" content="php, phalcon, phalcon php, php framework, faster php framework">
    <link rel="stylesheet" type="text/css" href="http://cdn.staticfile.org/twitter-bootstrap/3.3.6/css/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" href="/www/css/phalcon.min.css" />
    <link href='//fonts.googleapis.com/css?family=Open+Sans:700,400' rel='stylesheet' type='text/css'>
    <link href="//fonts.googleapis.com/css?family=Merriweather:400,700" rel="stylesheet" type="text/css" />
    <!--
    EUROPE <link href='//fonts.googleapis.com/css?family=Open+Sans:700,400&subset=latin-ext' rel='stylesheet' type='text/css'>
    GREEK <link href='//fonts.googleapis.com/css?family=Open+Sans:700,400&subset=greek-ext' rel='stylesheet' type='text/css'>
    RUSSIA <link href='//fonts.googleapis.com/css?family=Open+Sans:700,400&subset=cyrillic-ext,latin' rel='stylesheet' type='text/css'>
    -->

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

    <link rel="stylesheet" href="../static/pygments.css" type="text/css" />
    <link rel="stylesheet" href="../static/docs.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '3.0.1',
        COLLAPSE_MODINDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>

    <script src="http://cdn.staticfile.org/jquery/1.8.1/jquery.min.js"></script>
    <script type="text/javascript" src="../static/docs.js"></script>
    <link rel="shortcut icon" href="../static/favicon.ico"/>
    <link rel="top" title="Phalcon 3.0.1 文档" href="../index.html" />
    <link rel="next" title="资源文件管理（Assets Management）" href="assets.html" />
    <link rel="prev" title="使用视图（Using Views）" href="views.html" /> 
  </head>
  <body>

<header class="page-header">
    <nav class="navbar" role="navigation">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#main-menu-container">
                    <span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span>
                </button>
                <a class="navbar-brand phalcon-logo" href="/"><span itemprop="name" class="sr-only">Phalcon PHP</span></a>
            </div>

            <div class="collapse navbar-collapse navbar-right" id="main-menu-container">
                <ul class="nav navbar-nav main-menu">
                  <li class="first"><a href="//phalconphp.com/en/download" class="header-nav-link">Download</a></li>
                  <li><a href="//docs.phalconphp.com/en/latest/index.html" class="header-nav-link" target="_blank">Documentation</a></li>
                  <li><a href="//forum.phalconphp.com/" class="header-nav-link" target="_blank">Forum</a></li>
                  <li><a href="//blog.phalconphp.com/" class="header-nav-link" target="_blank">Blog</a></li>
                  <li><a href="//phalconist.com/" class="header-nav-link" target="_blank">Resources</a></li>
                  <li><a href="//phalconphp.com/en/about">About</a></li>
                  <li><div align="right">
                      <iframe src="https://ghbtns.com/github-btn.html?user=phalcon&amp;repo=cphalcon&amp;type=watch&amp;count=true&amp;size=large"
      allowtransparency="true" frameborder="0" scrolling="0" width="152px" height="30px"></iframe>
                    </div></li>
                </ul>
            </div>
        </div>
    </nav>
  </header>

<div class="heading">
    <div class="container">
        <div class="row">
            <h2>Documentation</h2>
        </div>
    </div>
</div>
    <div class="related">
      <ul>
        <li class="right" >
          <a href="../genindex.html" title="总目录"
             accesskey="I">索引</a></li>
        <li class="right" >
          <a href="assets.html" title="资源文件管理（Assets Management）"
             accesskey="N">下一页</a> |</li>
        <li class="right" >
          <a href="views.html" title="使用视图（Using Views）"
             accesskey="P">上一页</a> |</li>
        <li><a href="//phalconphp.com">Home</a> &raquo;</li>
        <li><a href="../index.html">Phalcon 3.0.1 文档</a> &raquo;</li> 
      </ul>
    </div>  

      <table width="100%" align="center" cellpadding="0" cellspacing="0">
        <tr>
      <td class="primary-box" width="25%" valign="top">
            <div>
            <div id="searchbox" style="">
                <!--<form class="search" action="http://readthedocs.org/search/project/" method="get">
                  <input type="search" name="q" size="25" placeholder="Search">
                  <input type="submit" value="Go">
                  <input type="hidden" name="selected_facets" value="project:">
                </form>-->
                <div style="width:200px;padding:10px">
                  <gcse:searchbox-only></gcse:searchbox-only>
                </div>
            </div>
            </div>
            <div style="padding:5px;padding-left:10px">
              <div id="carbonads-container">
                <div class="carbonad"><div id="azcarbon"></div>
                <script async type="text/javascript" src="//cdn.carbonads.com/carbon.js?zoneid=1673&serve=C6AILKT&placement=phalconphpcom" id="_carbonads_js"></script>
                </div></div>
            </div>
            <h3><a href="../index.html">內容目录</a></h3>
            <ul>
<li><a class="reference internal" href="#">视图助手 (Tags)（View Helpers (Tags)）</a><ul>
<li><a class="reference internal" href="#document-type-of-content">文档类型（Document Type of Content）</a></li>
<li><a class="reference internal" href="#generating-links">生成链接（Generating Links）</a></li>
<li><a class="reference internal" href="#creating-forms">创建表单（Creating Forms）</a></li>
<li><a class="reference internal" href="#helpers-to-generate-form-elements">使用助手生成表单控件（Helpers to Generate Form Elements）</a></li>
<li><a class="reference internal" href="#making-select-boxes">使用选择框（Making Select Boxes）</a></li>
<li><a class="reference internal" href="#html-assigning-html-attributes">设置 HTML 属性（Assigning HTML attributes）</a></li>
<li><a class="reference internal" href="#setting-helper-values">设置助手的值（Setting Helper Values）</a><ul>
<li><a class="reference internal" href="#from-controllers">通过控制器（From Controllers）</a></li>
<li><a class="reference internal" href="#from-the-request">通过请求（From the Request）</a></li>
<li><a class="reference internal" href="#specifying-values-directly">直接设置值（Specifying values directly）</a></li>
</ul>
</li>
<li><a class="reference internal" href="#changing-dynamically-the-document-title">动态设置文档标题（Changing dynamically the Document Title）</a></li>
<li><a class="reference internal" href="#static-content-helpers">静态内容助手（Static Content Helpers）</a><ul>
<li><a class="reference internal" href="#images">图片（Images）</a></li>
<li><a class="reference internal" href="#stylesheets">样式表（Stylesheets）</a></li>
<li><a class="reference internal" href="#javascript">脚本（Javascript）</a></li>
<li><a class="reference internal" href="#html5-html5-elements-generic-html-helper">HTML5 对象（HTML5 elements - generic HTML helper）</a></li>
</ul>
</li>
<li><a class="reference internal" href="#tag-service">标签服务（Tag Service）</a></li>
<li><a class="reference internal" href="#creating-your-own-helpers">创建助手（Creating your own helpers）</a></li>
</ul>
</li>
</ul>

            <h4>上一个主题</h4>
            <p class="topless"><a href="views.html" title="上一章">&lt; 使用视图（Using Views）</a></p>
            <h4>下一个主题</h4>
            <p class="topless"><a href="assets.html" title="下一章">资源文件管理（Assets Management） &gt;</a></p>
            <h3>本页</h3>
            <ul class="this-page-menu">
              <li><a href="../sources/reference/tags.md" rel="nofollow">显示源代码</a></li>
            </ul>
        </td>
          <td class="second-box" valign="top">
            <div class="document">
                <div class="documentwrapper">
                  <div class="bodywrapper">
                    <div class="body" >
                      
  <div class="section" id="tags-view-helpers-tags">
<h1>视图助手 (Tags)（View Helpers (Tags)）<a class="headerlink" href="#tags-view-helpers-tags" title="永久链接至标题">¶</a></h1>
<p>因为HTML标签的命名方式和很多标签属性，让书写HTML标签变成一项超级沉闷的工作。Phalcon提供 <a class="reference internal" href="../api/Phalcon_Tag.html"><em>Phalcon\Tag</em></a> 类来处理这些复杂而无趣的事情。</p>
<blockquote class="highlights">
<div>这个简单的指导不是一个完整的关于视图助手的文档，请查看 <a class="reference internal" href="../api/Phalcon_Tag.html"><em>Phalcon\Tag</em></a> 以获得视图助手的完整说明。</div></blockquote>
<div class="section" id="document-type-of-content">
<h2>文档类型（Document Type of Content）<a class="headerlink" href="#document-type-of-content" title="永久链接至标题">¶</a></h2>
<p>Phalcon 提供 <code class="code docutils literal"><span class="pre">Phalcon\Tag::setDoctype()</span></code> 方法可以设置输出内容的文档类型。此类型设置可能被其他的tag方法影响。</p>
<table border="1" class="docutils">
<colgroup>
<col width="48%" />
<col width="52%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">常量</th>
<th class="head">对应的文档类型</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>HTML32</td>
<td>HTML 3.2</td>
</tr>
<tr class="row-odd"><td>HTML401_STRICT</td>
<td>HTML 4.01 严格模式</td>
</tr>
<tr class="row-even"><td>HTML401_TRANSITIONAL</td>
<td>HTML 4.01 过渡模式</td>
</tr>
<tr class="row-odd"><td>HTML401_FRAMESET</td>
<td>HTML 4.01 Frameset</td>
</tr>
<tr class="row-even"><td>HTML5</td>
<td>HTML 5</td>
</tr>
<tr class="row-odd"><td>XHTML10_STRICT</td>
<td>XHTML 1.0 严格模式</td>
</tr>
<tr class="row-even"><td>XHTML10_TRANSITIONAL</td>
<td>XHTML 1.0 过渡模式</td>
</tr>
<tr class="row-odd"><td>XHTML10_FRAMESET</td>
<td>XHTML 1.0 Frameset</td>
</tr>
<tr class="row-even"><td>XHTML11</td>
<td>XHTML 1.1</td>
</tr>
<tr class="row-odd"><td>XHTML20</td>
<td>XHTML 2.0</td>
</tr>
<tr class="row-even"><td>XHTML5</td>
<td>XHTML 5</td>
</tr>
</tbody>
</table>
<p>设置文档类型:</p>
<div class="highlight-php"><div class="highlight"><pre><span class="cp">&lt;?php</span>

<span class="k">use</span> <span class="nx">Phalcon\Tag</span><span class="p">;</span>

<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">setDoctype</span><span class="p">(</span><span class="nx">Tag</span><span class="o">::</span><span class="na">HTML401_STRICT</span><span class="p">);</span>

<span class="cp">?&gt;</span><span class="x"></span>
</pre></div>
</div>
<p>获取文档类型:</p>
<div class="highlight-html+php"><div class="highlight"><pre><span class="cp">&lt;?</span><span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">getDoctype</span><span class="p">()</span> <span class="cp">?&gt;</span>
<span class="nt">&lt;html&gt;</span>
<span class="c">&lt;!-- your HTML code --&gt;</span>
<span class="nt">&lt;/html&gt;</span>
</pre></div>
</div>
<p>如下的html代码将被生成:</p>
<div class="highlight-html"><div class="highlight"><pre><span class="cp">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01//EN&quot;</span>
<span class="cp">        &quot;http://www.w3.org/TR/html4/strict.dtd&quot;&gt;</span>
<span class="nt">&lt;html&gt;</span>
<span class="c">&lt;!-- your HTML code --&gt;</span>
<span class="nt">&lt;/html&gt;</span>
</pre></div>
</div>
<p>Volt 语法:</p>
<div class="highlight-html+jinja"><div class="highlight"><pre><span class="cp">{{</span> <span class="nv">get_doctype</span><span class="o">()</span> <span class="cp">}}</span>
<span class="nt">&lt;html&gt;</span>
<span class="c">&lt;!-- your HTML code --&gt;</span>
<span class="nt">&lt;/html&gt;</span>
</pre></div>
</div>
</div>
<div class="section" id="generating-links">
<h2>生成链接（Generating Links）<a class="headerlink" href="#generating-links" title="永久链接至标题">¶</a></h2>
<p>每一个普通的web应用都需要生成超链接去让我们在不同的页面之间进行导航。我们可以使用如下的方法创建指向我们站内的超链接：</p>
<div class="highlight-html+php"><div class="highlight"><pre><span class="c">&lt;!-- for the default route --&gt;</span>
<span class="cp">&lt;?</span><span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">linkTo</span><span class="p">(</span><span class="s2">&quot;products/search&quot;</span><span class="p">,</span> <span class="s2">&quot;Search&quot;</span><span class="p">)</span> <span class="cp">?&gt;</span>

<span class="c">&lt;!-- with CSS attributes --&gt;</span>
<span class="cp">&lt;?</span><span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">linkTo</span><span class="p">([</span><span class="s2">&quot;products/edit/10&quot;</span><span class="p">,</span> <span class="s2">&quot;Edit&quot;</span><span class="p">,</span> <span class="s2">&quot;class&quot;</span> <span class="o">=&gt;</span> <span class="s2">&quot;edit-btn&quot;</span><span class="p">])</span> <span class="cp">?&gt;</span>

<span class="c">&lt;!-- for a named route --&gt;</span>
<span class="cp">&lt;?</span><span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">linkTo</span><span class="p">([[</span><span class="s2">&quot;for&quot;</span> <span class="o">=&gt;</span> <span class="s2">&quot;show-product&quot;</span><span class="p">,</span> <span class="s2">&quot;title&quot;</span> <span class="o">=&gt;</span> <span class="mi">123</span><span class="p">,</span> <span class="s2">&quot;name&quot;</span> <span class="o">=&gt;</span> <span class="s2">&quot;carrots&quot;</span><span class="p">],</span> <span class="s2">&quot;Show&quot;</span><span class="p">])</span> <span class="cp">?&gt;</span>
</pre></div>
</div>
<p>事实上，上例所有URL都是被 <a class="reference internal" href="url.html"><em>Phalcon\Mvc\Url</em></a> 生成的。</p>
<p>使用Volt生成超链接的例子:</p>
<div class="highlight-html+jinja"><div class="highlight"><pre><span class="c">&lt;!-- for the default route --&gt;</span>
<span class="cp">{{</span> <span class="nv">link_to</span><span class="o">(</span><span class="s2">&quot;products/search&quot;</span><span class="o">,</span> <span class="s2">&quot;Search&quot;</span><span class="o">)</span> <span class="cp">}}</span>

<span class="c">&lt;!-- for a named route --&gt;</span>
<span class="cp">{{</span> <span class="nv">link_to</span><span class="o">([</span><span class="s2">&quot;for&quot;</span><span class="o">:</span> <span class="s2">&quot;show-product&quot;</span><span class="o">,</span> <span class="s2">&quot;id&quot;</span><span class="o">:</span> <span class="m">123</span><span class="o">,</span> <span class="s2">&quot;name&quot;</span><span class="o">:</span> <span class="s2">&quot;carrots&quot;</span><span class="o">],</span> <span class="s2">&quot;Show&quot;</span><span class="o">)</span> <span class="cp">}}</span>

<span class="c">&lt;!-- for a named route with a HTML class --&gt;</span>
<span class="cp">{{</span> <span class="nv">link_to</span><span class="o">([</span><span class="s2">&quot;for&quot;</span><span class="o">:</span> <span class="s2">&quot;show-product&quot;</span><span class="o">,</span> <span class="s2">&quot;id&quot;</span><span class="o">:</span> <span class="m">123</span><span class="o">,</span> <span class="s2">&quot;name&quot;</span><span class="o">:</span> <span class="s2">&quot;carrots&quot;</span><span class="o">],</span> <span class="s2">&quot;Show&quot;</span><span class="o">,</span> <span class="s2">&quot;class&quot;</span><span class="o">:</span> <span class="s2">&quot;edit-btn&quot;</span><span class="o">)</span> <span class="cp">}}</span>
</pre></div>
</div>
</div>
<div class="section" id="creating-forms">
<h2>创建表单（Creating Forms）<a class="headerlink" href="#creating-forms" title="永久链接至标题">¶</a></h2>
<p>在Web应用中，表单是获取用户输入的重要工具，下面的例子显示了使用视图助手(tag)如何去生成一个简单的form表单。</p>
<div class="highlight-html+php"><div class="highlight"><pre><span class="c">&lt;!-- Sending the form by method POST --&gt;</span>
<span class="cp">&lt;?</span><span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">form</span><span class="p">(</span><span class="s2">&quot;products/search&quot;</span><span class="p">)</span> <span class="cp">?&gt;</span>
    <span class="nt">&lt;label</span> <span class="na">for=</span><span class="s">&quot;q&quot;</span><span class="nt">&gt;</span>Search:<span class="nt">&lt;/label&gt;</span>

    <span class="cp">&lt;?</span><span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">textField</span><span class="p">(</span><span class="s2">&quot;q&quot;</span><span class="p">)</span> <span class="cp">?&gt;</span>

    <span class="cp">&lt;?</span><span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">submitButton</span><span class="p">(</span><span class="s2">&quot;Search&quot;</span><span class="p">)</span> <span class="cp">?&gt;</span>
<span class="cp">&lt;?</span><span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">endForm</span><span class="p">()</span> <span class="cp">?&gt;</span>

<span class="c">&lt;!-- Specifying another method or attributes for the FORM tag --&gt;</span>
<span class="cp">&lt;?</span><span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">form</span><span class="p">([</span><span class="s2">&quot;products/search&quot;</span><span class="p">,</span> <span class="s2">&quot;method&quot;</span> <span class="o">=&gt;</span> <span class="s2">&quot;get&quot;</span><span class="p">]);</span> <span class="cp">?&gt;</span>
    <span class="nt">&lt;label</span> <span class="na">for=</span><span class="s">&quot;q&quot;</span><span class="nt">&gt;</span>Search:<span class="nt">&lt;/label&gt;</span>

    <span class="cp">&lt;?</span><span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">textField</span><span class="p">(</span><span class="s2">&quot;q&quot;</span><span class="p">);</span> <span class="cp">?&gt;</span>

    <span class="cp">&lt;?</span><span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">submitButton</span><span class="p">(</span><span class="s2">&quot;Search&quot;</span><span class="p">);</span> <span class="cp">?&gt;</span>
<span class="cp">&lt;?</span><span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">endForm</span><span class="p">()</span> <span class="cp">?&gt;</span>
</pre></div>
</div>
<p>以上代码会生成如下的html:</p>
<div class="highlight-html"><div class="highlight"><pre><span class="nt">&lt;form</span> <span class="na">action=</span><span class="s">&quot;/store/products/search/&quot;</span> <span class="na">method=</span><span class="s">&quot;get&quot;</span><span class="nt">&gt;</span>
    <span class="nt">&lt;label</span> <span class="na">for=</span><span class="s">&quot;q&quot;</span><span class="nt">&gt;</span>Search:<span class="nt">&lt;/label&gt;</span>

    <span class="nt">&lt;input</span> <span class="na">type=</span><span class="s">&quot;text&quot;</span> <span class="na">id=</span><span class="s">&quot;q&quot;</span> <span class="na">value=</span><span class="s">&quot;&quot;</span> <span class="na">name=</span><span class="s">&quot;q&quot;</span> <span class="nt">/&gt;</span>

    <span class="nt">&lt;input</span> <span class="na">type=</span><span class="s">&quot;submit&quot;</span> <span class="na">value=</span><span class="s">&quot;Search&quot;</span> <span class="nt">/&gt;</span>
<span class="nt">&lt;/form&gt;</span>
</pre></div>
</div>
<p>使用Volt生成表单:</p>
<div class="highlight-html+jinja"><div class="highlight"><pre><span class="c">&lt;!-- Specifying another method or attributes for the FORM tag --&gt;</span>
<span class="cp">{{</span> <span class="nv">form</span><span class="o">(</span><span class="s2">&quot;products/search&quot;</span><span class="o">,</span> <span class="s2">&quot;method&quot;</span><span class="o">:</span> <span class="s2">&quot;get&quot;</span><span class="o">)</span> <span class="cp">}}</span>
    <span class="nt">&lt;label</span> <span class="na">for=</span><span class="s">&quot;q&quot;</span><span class="nt">&gt;</span>Search:<span class="nt">&lt;/label&gt;</span>

    <span class="cp">{{</span> <span class="nv">text_field</span><span class="o">(</span><span class="s2">&quot;q&quot;</span><span class="o">)</span> <span class="cp">}}</span>

    <span class="cp">{{</span> <span class="nv">submit_button</span><span class="o">(</span><span class="s2">&quot;Search&quot;</span><span class="o">)</span> <span class="cp">}}</span>
<span class="cp">{{</span> <span class="nv">endForm</span><span class="o">()</span> <span class="cp">}}</span>
</pre></div>
</div>
<p>Phalcon也提供了 <a class="reference internal" href="forms.html"><em>form builder</em></a> 类去以面向对象的风格去生成这样的表单。</p>
</div>
<div class="section" id="helpers-to-generate-form-elements">
<h2>使用助手生成表单控件（Helpers to Generate Form Elements）<a class="headerlink" href="#helpers-to-generate-form-elements" title="永久链接至标题">¶</a></h2>
<p>Phalcon 提供了一系列的方法去生成例如文本域(text)，按钮(button)和其他的一些form表单元素。提供给所有方法(helper)的第一个参数都是需要创建的表单元素的名称(name属性)。当提交表单的时候，这个名称将被和form表单数据一起传输。在控制器中，你可以使用request对象 (<code class="code docutils literal"><span class="pre">$this-&gt;request</span></code>) 的 <code class="code docutils literal"><span class="pre">getPost()</span></code> 和 <code class="code docutils literal"><span class="pre">getQuery()</span></code> 方法结合之前定义的名字(name属性)来获取到这些值。</p>
<div class="highlight-html+php"><div class="highlight"><pre><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">textField</span><span class="p">(</span><span class="s2">&quot;username&quot;</span><span class="p">)</span> <span class="cp">?&gt;</span>

<span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">textArea</span><span class="p">(</span>
    <span class="p">[</span>
        <span class="s2">&quot;comment&quot;</span><span class="p">,</span>
        <span class="s2">&quot;This is the content of the text-area&quot;</span><span class="p">,</span>
        <span class="s2">&quot;cols&quot;</span> <span class="o">=&gt;</span> <span class="s2">&quot;6&quot;</span><span class="p">,</span>
        <span class="s2">&quot;rows&quot;</span> <span class="o">=&gt;</span> <span class="mi">20</span><span class="p">,</span>
    <span class="p">]</span>
<span class="p">)</span> <span class="cp">?&gt;</span>

<span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">passwordField</span><span class="p">(</span>
    <span class="p">[</span>
        <span class="s2">&quot;password&quot;</span><span class="p">,</span>
        <span class="s2">&quot;size&quot;</span> <span class="o">=&gt;</span> <span class="mi">30</span><span class="p">,</span>
    <span class="p">]</span>
<span class="p">)</span> <span class="cp">?&gt;</span>

<span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">hiddenField</span><span class="p">(</span>
    <span class="p">[</span>
        <span class="s2">&quot;parent_id&quot;</span><span class="p">,</span>
        <span class="s2">&quot;value&quot;</span> <span class="o">=&gt;</span> <span class="s2">&quot;5&quot;</span><span class="p">,</span>
    <span class="p">]</span>
<span class="p">)</span> <span class="cp">?&gt;</span>
</pre></div>
</div>
<p>Volt 的语法:</p>
<div class="highlight-html+jinja"><div class="highlight"><pre><span class="cp">{{</span> <span class="nv">text_field</span><span class="o">(</span><span class="s2">&quot;username&quot;</span><span class="o">)</span> <span class="cp">}}</span>

<span class="cp">{{</span> <span class="nv">text_area</span><span class="o">(</span><span class="s2">&quot;comment&quot;</span><span class="o">,</span> <span class="s2">&quot;This is the content&quot;</span><span class="o">,</span> <span class="s2">&quot;cols&quot;</span><span class="o">:</span> <span class="s2">&quot;6&quot;</span><span class="o">,</span> <span class="s2">&quot;rows&quot;</span><span class="o">:</span> <span class="m">20</span><span class="o">)</span> <span class="cp">}}</span>

<span class="cp">{{</span> <span class="nv">password_field</span><span class="o">(</span><span class="s2">&quot;password&quot;</span><span class="o">,</span> <span class="s2">&quot;size&quot;</span><span class="o">:</span> <span class="m">30</span><span class="o">)</span> <span class="cp">}}</span>

<span class="cp">{{</span> <span class="nv">hidden_field</span><span class="o">(</span><span class="s2">&quot;parent_id&quot;</span><span class="o">,</span> <span class="s2">&quot;value&quot;</span><span class="o">:</span> <span class="s2">&quot;5&quot;</span><span class="o">)</span> <span class="cp">}}</span>
</pre></div>
</div>
</div>
<div class="section" id="making-select-boxes">
<h2>使用选择框（Making Select Boxes）<a class="headerlink" href="#making-select-boxes" title="永久链接至标题">¶</a></h2>
<p>生成选择框(select)很简单,特别是当你已经把相关的数据存储在了PHP的关联数组中。生成select的方法是 <code class="code docutils literal"><span class="pre">Phalcon\Tag::select()</span></code> 和 <code class="code docutils literal"><span class="pre">Phalcon\Tag::selectStatic()</span></code> 。方法 <code class="code docutils literal"><span class="pre">Phalcon\Tag::select()</span></code> 与 <a class="reference internal" href="models.html"><em>Phalcon\Mvc\Model</em></a> 一起使用会更好。当然 <code class="code docutils literal"><span class="pre">Phalcon\Tag::selectStatic()</span></code> 也可以和PHP的数组一起工作。</p>
<div class="highlight-php"><div class="highlight"><pre><span class="cp">&lt;?php</span>

<span class="nv">$products</span> <span class="o">=</span> <span class="nx">Products</span><span class="o">::</span><span class="na">find</span><span class="p">(</span><span class="s2">&quot;type = &#39;vegetables&#39;&quot;</span><span class="p">);</span>

<span class="c1">// Using data from a resultset</span>
<span class="k">echo</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">select</span><span class="p">(</span>
    <span class="p">[</span>
        <span class="s2">&quot;productId&quot;</span><span class="p">,</span>
        <span class="nv">$products</span><span class="p">,</span>
        <span class="s2">&quot;using&quot;</span> <span class="o">=&gt;</span> <span class="p">[</span>
            <span class="s2">&quot;id&quot;</span><span class="p">,</span>
            <span class="s2">&quot;name&quot;</span><span class="p">,</span>
        <span class="p">]</span>
    <span class="p">]</span>
<span class="p">);</span>

<span class="c1">// Using data from an array</span>
<span class="k">echo</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">selectStatic</span><span class="p">(</span>
    <span class="p">[</span>
        <span class="s2">&quot;status&quot;</span><span class="p">,</span>
        <span class="p">[</span>
            <span class="s2">&quot;A&quot;</span> <span class="o">=&gt;</span> <span class="s2">&quot;Active&quot;</span><span class="p">,</span>
            <span class="s2">&quot;I&quot;</span> <span class="o">=&gt;</span> <span class="s2">&quot;Inactive&quot;</span><span class="p">,</span>
        <span class="p">]</span>
    <span class="p">]</span>
<span class="p">);</span>
</pre></div>
</div>
<p>以下HTML代码将会被生成:</p>
<div class="highlight-html"><div class="highlight"><pre><span class="nt">&lt;select</span> <span class="na">id=</span><span class="s">&quot;productId&quot;</span> <span class="na">name=</span><span class="s">&quot;productId&quot;</span><span class="nt">&gt;</span>
    <span class="nt">&lt;option</span> <span class="na">value=</span><span class="s">&quot;101&quot;</span><span class="nt">&gt;</span>Tomato<span class="nt">&lt;/option&gt;</span>
    <span class="nt">&lt;option</span> <span class="na">value=</span><span class="s">&quot;102&quot;</span><span class="nt">&gt;</span>Lettuce<span class="nt">&lt;/option&gt;</span>
    <span class="nt">&lt;option</span> <span class="na">value=</span><span class="s">&quot;103&quot;</span><span class="nt">&gt;</span>Beans<span class="nt">&lt;/option&gt;</span>
<span class="nt">&lt;/select&gt;</span>

<span class="nt">&lt;select</span> <span class="na">id=</span><span class="s">&quot;status&quot;</span> <span class="na">name=</span><span class="s">&quot;status&quot;</span><span class="nt">&gt;</span>
    <span class="nt">&lt;option</span> <span class="na">value=</span><span class="s">&quot;A&quot;</span><span class="nt">&gt;</span>Active<span class="nt">&lt;/option&gt;</span>
    <span class="nt">&lt;option</span> <span class="na">value=</span><span class="s">&quot;I&quot;</span><span class="nt">&gt;</span>Inactive<span class="nt">&lt;/option&gt;</span>
<span class="nt">&lt;/select&gt;</span>
</pre></div>
</div>
<p>你可以添加一个空的选项(option)到被生成的HTML页面中:</p>
<div class="highlight-php"><div class="highlight"><pre><span class="cp">&lt;?php</span>

<span class="nv">$products</span> <span class="o">=</span> <span class="nx">Products</span><span class="o">::</span><span class="na">find</span><span class="p">(</span><span class="s2">&quot;type = &#39;vegetables&#39;&quot;</span><span class="p">);</span>

<span class="c1">// Creating a Select Tag with an empty option</span>
<span class="k">echo</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">select</span><span class="p">(</span>
    <span class="p">[</span>
        <span class="s2">&quot;productId&quot;</span><span class="p">,</span>
        <span class="nv">$products</span><span class="p">,</span>
        <span class="s2">&quot;using&quot;</span>    <span class="o">=&gt;</span> <span class="p">[</span>
            <span class="s2">&quot;id&quot;</span><span class="p">,</span>
            <span class="s2">&quot;name&quot;</span><span class="p">,</span>
        <span class="p">],</span>
        <span class="s2">&quot;useEmpty&quot;</span> <span class="o">=&gt;</span> <span class="k">true</span><span class="p">,</span>
    <span class="p">]</span>
<span class="p">);</span>
</pre></div>
</div>
<p>生成的HTML如下:</p>
<div class="highlight-html"><div class="highlight"><pre><span class="nt">&lt;select</span> <span class="na">id=</span><span class="s">&quot;productId&quot;</span> <span class="na">name=</span><span class="s">&quot;productId&quot;</span><span class="nt">&gt;</span>
    <span class="nt">&lt;option</span> <span class="na">value=</span><span class="s">&quot;&quot;</span><span class="nt">&gt;</span>Choose..<span class="nt">&lt;/option&gt;</span>
    <span class="nt">&lt;option</span> <span class="na">value=</span><span class="s">&quot;101&quot;</span><span class="nt">&gt;</span>Tomato<span class="nt">&lt;/option&gt;</span>
    <span class="nt">&lt;option</span> <span class="na">value=</span><span class="s">&quot;102&quot;</span><span class="nt">&gt;</span>Lettuce<span class="nt">&lt;/option&gt;</span>
    <span class="nt">&lt;option</span> <span class="na">value=</span><span class="s">&quot;103&quot;</span><span class="nt">&gt;</span>Beans<span class="nt">&lt;/option&gt;</span>
<span class="nt">&lt;/select&gt;</span>
</pre></div>
</div>
<div class="highlight-php"><div class="highlight"><pre><span class="cp">&lt;?php</span>

<span class="nv">$products</span> <span class="o">=</span> <span class="nx">Products</span><span class="o">::</span><span class="na">find</span><span class="p">(</span><span class="s2">&quot;type = &#39;vegetables&#39;&quot;</span><span class="p">);</span>

<span class="c1">// Creating a Select Tag with an empty option with default text</span>
<span class="k">echo</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">select</span><span class="p">(</span>
    <span class="p">[</span>
        <span class="s2">&quot;productId&quot;</span><span class="p">,</span>
        <span class="nv">$products</span><span class="p">,</span>
        <span class="s2">&quot;using&quot;</span>      <span class="o">=&gt;</span> <span class="p">[</span>
            <span class="s2">&quot;id&quot;</span><span class="p">,</span>
            <span class="s2">&quot;name&quot;</span><span class="p">,</span>
        <span class="p">],</span>
        <span class="s2">&quot;useEmpty&quot;</span>   <span class="o">=&gt;</span> <span class="k">true</span><span class="p">,</span>
        <span class="s2">&quot;emptyText&quot;</span>  <span class="o">=&gt;</span> <span class="s2">&quot;Please, choose one...&quot;</span><span class="p">,</span>
        <span class="s2">&quot;emptyValue&quot;</span> <span class="o">=&gt;</span> <span class="s2">&quot;@&quot;</span><span class="p">,</span>
    <span class="p">]</span>
<span class="p">);</span>
</pre></div>
</div>
<div class="highlight-html"><div class="highlight"><pre><span class="nt">&lt;select</span> <span class="na">id=</span><span class="s">&quot;productId&quot;</span> <span class="na">name=</span><span class="s">&quot;productId&quot;</span><span class="nt">&gt;</span>
    <span class="nt">&lt;option</span> <span class="na">value=</span><span class="s">&quot;@&quot;</span><span class="nt">&gt;</span>Please, choose one..<span class="nt">&lt;/option&gt;</span>
    <span class="nt">&lt;option</span> <span class="na">value=</span><span class="s">&quot;101&quot;</span><span class="nt">&gt;</span>Tomato<span class="nt">&lt;/option&gt;</span>
    <span class="nt">&lt;option</span> <span class="na">value=</span><span class="s">&quot;102&quot;</span><span class="nt">&gt;</span>Lettuce<span class="nt">&lt;/option&gt;</span>
    <span class="nt">&lt;option</span> <span class="na">value=</span><span class="s">&quot;103&quot;</span><span class="nt">&gt;</span>Beans<span class="nt">&lt;/option&gt;</span>
<span class="nt">&lt;/select&gt;</span>
</pre></div>
</div>
<p>以Volt的语法生成以上的select选择框</p>
<div class="highlight-jinja"><div class="highlight"><pre><span class="c">{# Creating a Select Tag with an empty option with default text #}</span><span class="x"></span>
<span class="cp">{{</span> <span class="nv">select</span><span class="o">(</span><span class="s1">&#39;productId&#39;</span><span class="o">,</span> <span class="nv">products</span><span class="o">,</span> <span class="s1">&#39;using&#39;</span><span class="o">:</span> <span class="o">[</span><span class="s1">&#39;id&#39;</span><span class="o">,</span> <span class="s1">&#39;name&#39;</span><span class="o">],</span>
    <span class="s1">&#39;useEmpty&#39;</span><span class="o">:</span> <span class="kp">true</span><span class="o">,</span> <span class="s1">&#39;emptyText&#39;</span><span class="o">:</span> <span class="s1">&#39;Please, choose one...&#39;</span><span class="o">,</span> <span class="s1">&#39;emptyValue&#39;</span><span class="o">:</span> <span class="s1">&#39;@&#39;</span><span class="o">)</span> <span class="cp">}}</span><span class="x"></span>
</pre></div>
</div>
</div>
<div class="section" id="html-assigning-html-attributes">
<h2>设置 HTML 属性（Assigning HTML attributes）<a class="headerlink" href="#html-assigning-html-attributes" title="永久链接至标题">¶</a></h2>
<p>所有的方法的第一个参数可以是一个数组，这个数组包含了这个被生成的HTML元素额外的属性。</p>
<div class="highlight-html+php"><div class="highlight"><pre><span class="cp">&lt;?php</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">textField</span><span class="p">(</span>
    <span class="p">[</span>
        <span class="s2">&quot;price&quot;</span><span class="p">,</span>
        <span class="s2">&quot;size&quot;</span>        <span class="o">=&gt;</span> <span class="mi">20</span><span class="p">,</span>
        <span class="s2">&quot;maxlength&quot;</span>   <span class="o">=&gt;</span> <span class="mi">30</span><span class="p">,</span>
        <span class="s2">&quot;placeholder&quot;</span> <span class="o">=&gt;</span> <span class="s2">&quot;Enter a price&quot;</span><span class="p">,</span>
    <span class="p">]</span>
<span class="p">)</span> <span class="cp">?&gt;</span>
</pre></div>
</div>
<p>Volt语法:</p>
<div class="highlight-jinja"><div class="highlight"><pre><span class="cp">{{</span> <span class="nv">text_field</span><span class="o">(</span><span class="s2">&quot;price&quot;</span><span class="o">,</span> <span class="s2">&quot;size&quot;</span><span class="o">:</span> <span class="m">20</span><span class="o">,</span> <span class="s2">&quot;maxlength&quot;</span><span class="o">:</span> <span class="m">30</span><span class="o">,</span> <span class="s2">&quot;placeholder&quot;</span><span class="o">:</span> <span class="s2">&quot;Enter a price&quot;</span><span class="o">)</span> <span class="cp">}}</span><span class="x"></span>
</pre></div>
</div>
<p>以下的HTML代码将被生成。</p>
<div class="highlight-html"><div class="highlight"><pre><span class="nt">&lt;input</span> <span class="na">type=</span><span class="s">&quot;text&quot;</span> <span class="na">name=</span><span class="s">&quot;price&quot;</span> <span class="na">id=</span><span class="s">&quot;price&quot;</span> <span class="na">size=</span><span class="s">&quot;20&quot;</span> <span class="na">maxlength=</span><span class="s">&quot;30&quot;</span>
    <span class="na">placeholder=</span><span class="s">&quot;Enter a price&quot;</span> <span class="nt">/&gt;</span>
</pre></div>
</div>
</div>
<div class="section" id="setting-helper-values">
<h2>设置助手的值（Setting Helper Values）<a class="headerlink" href="#setting-helper-values" title="永久链接至标题">¶</a></h2>
<div class="section" id="from-controllers">
<h3>通过控制器（From Controllers）<a class="headerlink" href="#from-controllers" title="永久链接至标题">¶</a></h3>
<p>使用MVC框架编程时的一个好习惯是给form元素在视图中设定一个明确的值。你可以直接使用 <code class="code docutils literal"><span class="pre">Phalcon\Tag::setDefault()</span></code> 在控制器中设置这个值。这个方法为所有的视图助手的方法预先设定了一个值，如果任意一个视图助手方法有一个和此预设值相匹配的名字，这个值将会被使用，除非那个视图方法明确的指定了这个值。</p>
<div class="highlight-php"><div class="highlight"><pre><span class="cp">&lt;?php</span>

<span class="k">use</span> <span class="nx">Phalcon\Mvc\Controller</span><span class="p">;</span>

<span class="k">class</span> <span class="nc">ProductsController</span> <span class="k">extends</span> <span class="nx">Controller</span>
<span class="p">{</span>
    <span class="k">public</span> <span class="k">function</span> <span class="nf">indexAction</span><span class="p">()</span>
    <span class="p">{</span>
        <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">setDefault</span><span class="p">(</span><span class="s2">&quot;color&quot;</span><span class="p">,</span> <span class="s2">&quot;Blue&quot;</span><span class="p">);</span>
    <span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<p>例如，在视图中一个选择框助手方法(select helper)匹配到了这个之前被预设的值&#8221;color&#8221;</p>
<div class="highlight-php"><div class="highlight"><pre><span class="cp">&lt;?php</span>

<span class="k">echo</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">selectStatic</span><span class="p">(</span>
    <span class="p">[</span>
        <span class="s2">&quot;color&quot;</span><span class="p">,</span>
        <span class="p">[</span>
            <span class="s2">&quot;Yellow&quot;</span> <span class="o">=&gt;</span> <span class="s2">&quot;Yellow&quot;</span><span class="p">,</span>
            <span class="s2">&quot;Blue&quot;</span>   <span class="o">=&gt;</span> <span class="s2">&quot;Blue&quot;</span><span class="p">,</span>
            <span class="s2">&quot;Red&quot;</span>    <span class="o">=&gt;</span> <span class="s2">&quot;Red&quot;</span><span class="p">,</span>
        <span class="p">]</span>
    <span class="p">]</span>
<span class="p">);</span>
</pre></div>
</div>
<p>当这个选择框被生成的时候，&#8221;Blue&#8221;将被默认选中。</p>
<div class="highlight-html"><div class="highlight"><pre><span class="nt">&lt;select</span> <span class="na">id=</span><span class="s">&quot;color&quot;</span> <span class="na">name=</span><span class="s">&quot;color&quot;</span><span class="nt">&gt;</span>
    <span class="nt">&lt;option</span> <span class="na">value=</span><span class="s">&quot;Yellow&quot;</span><span class="nt">&gt;</span>Yellow<span class="nt">&lt;/option&gt;</span>
    <span class="nt">&lt;option</span> <span class="na">value=</span><span class="s">&quot;Blue&quot;</span> <span class="na">selected=</span><span class="s">&quot;selected&quot;</span><span class="nt">&gt;</span>Blue<span class="nt">&lt;/option&gt;</span>
    <span class="nt">&lt;option</span> <span class="na">value=</span><span class="s">&quot;Red&quot;</span><span class="nt">&gt;</span>Red<span class="nt">&lt;/option&gt;</span>
<span class="nt">&lt;/select&gt;</span>
</pre></div>
</div>
</div>
<div class="section" id="from-the-request">
<h3>通过请求（From the Request）<a class="headerlink" href="#from-the-request" title="永久链接至标题">¶</a></h3>
<blockquote>
<div><a class="reference internal" href="../api/Phalcon_Tag.html"><em>Phalcon\Tag</em></a> 助手有一个特性，它可以在用户请求的时候保持表单的值。这个特性让你在不损失任何输入数据的情况下显示一些确认信息。</div></blockquote>
</div>
<div class="section" id="specifying-values-directly">
<h3>直接设置值（Specifying values directly）<a class="headerlink" href="#specifying-values-directly" title="永久链接至标题">¶</a></h3>
<p>所有的表单方法都支持参数&#8221;value&#8221;。你可以直接设置一个明确的值给表单方法。当这个值被明确设定的时候，任何通过 setDefault() 或者通过 请求(request) 所设置的值将被直接忽略。</p>
</div>
</div>
<div class="section" id="changing-dynamically-the-document-title">
<h2>动态设置文档标题（Changing dynamically the Document Title）<a class="headerlink" href="#changing-dynamically-the-document-title" title="永久链接至标题">¶</a></h2>
<p><a class="reference internal" href="../api/Phalcon_Tag.html"><em>Phalcon\Tag</em></a> 类提供了一些方法，让我们可以在控制器中动态地设置HTML文档的标题(title)。</p>
<div class="highlight-php"><div class="highlight"><pre><span class="cp">&lt;?php</span>

<span class="k">use</span> <span class="nx">Phalcon\Mvc\Controller</span><span class="p">;</span>

<span class="k">class</span> <span class="nc">PostsController</span> <span class="k">extends</span> <span class="nx">Controller</span>
<span class="p">{</span>
    <span class="k">public</span> <span class="k">function</span> <span class="nf">initialize</span><span class="p">()</span>
    <span class="p">{</span>
        <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">setTitle</span><span class="p">(</span><span class="s2">&quot;Your Website&quot;</span><span class="p">);</span>
    <span class="p">}</span>

    <span class="k">public</span> <span class="k">function</span> <span class="nf">indexAction</span><span class="p">()</span>
    <span class="p">{</span>
        <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">prependTitle</span><span class="p">(</span><span class="s2">&quot;Index of Posts - &quot;</span><span class="p">);</span>
    <span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<div class="highlight-html+php"><div class="highlight"><pre><span class="nt">&lt;html&gt;</span>
    <span class="nt">&lt;head&gt;</span>
        <span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">getTitle</span><span class="p">();</span> <span class="cp">?&gt;</span>
    <span class="nt">&lt;/head&gt;</span>

    <span class="nt">&lt;body&gt;</span>

    <span class="nt">&lt;/body&gt;</span>
<span class="nt">&lt;/html&gt;</span>
</pre></div>
</div>
<p>以下的HTML代码将会被生成:</p>
<div class="highlight-html+php"><div class="highlight"><pre><span class="nt">&lt;html&gt;</span>
    <span class="nt">&lt;head&gt;</span>
        <span class="nt">&lt;title&gt;</span>Index of Posts - Your Website<span class="nt">&lt;/title&gt;</span>
    <span class="nt">&lt;/head&gt;</span>

    <span class="nt">&lt;body&gt;</span>

    <span class="nt">&lt;/body&gt;</span>
<span class="nt">&lt;/html&gt;</span>
</pre></div>
</div>
</div>
<div class="section" id="static-content-helpers">
<h2>静态内容助手（Static Content Helpers）<a class="headerlink" href="#static-content-helpers" title="永久链接至标题">¶</a></h2>
<p><a class="reference internal" href="../api/Phalcon_Tag.html"><em>Phalcon\Tag</em></a> 也提供一些其他的方法去生成一些其他的标签，例如脚本(script),超链接(link)或者图片(img)。它可以帮助你很快的生成一些你应用中的静态资源</p>
<div class="section" id="images">
<h3>图片（Images）<a class="headerlink" href="#images" title="永久链接至标题">¶</a></h3>
<div class="highlight-php"><div class="highlight"><pre><span class="cp">&lt;?php</span>

<span class="c1">// Generate &lt;img src=&quot;/your-app/img/hello.gif&quot;&gt;</span>
<span class="k">echo</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">image</span><span class="p">(</span><span class="s2">&quot;img/hello.gif&quot;</span><span class="p">);</span>

<span class="c1">// Generate &lt;img alt=&quot;alternative text&quot; src=&quot;/your-app/img/hello.gif&quot;&gt;</span>
<span class="k">echo</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">image</span><span class="p">(</span>
    <span class="p">[</span>
       <span class="s2">&quot;img/hello.gif&quot;</span><span class="p">,</span>
       <span class="s2">&quot;alt&quot;</span> <span class="o">=&gt;</span> <span class="s2">&quot;alternative text&quot;</span><span class="p">,</span>
    <span class="p">]</span>
<span class="p">);</span>
</pre></div>
</div>
<p>Volt 语法:</p>
<div class="highlight-jinja"><div class="highlight"><pre><span class="c">{# Generate &lt;img src=&quot;/your-app/img/hello.gif&quot;&gt; #}</span><span class="x"></span>
<span class="cp">{{</span> <span class="nv">image</span><span class="o">(</span><span class="s2">&quot;img/hello.gif&quot;</span><span class="o">)</span> <span class="cp">}}</span><span class="x"></span>

<span class="c">{# Generate &lt;img alt=&quot;alternative text&quot; src=&quot;/your-app/img/hello.gif&quot;&gt; #}</span><span class="x"></span>
<span class="cp">{{</span> <span class="nv">image</span><span class="o">(</span><span class="s2">&quot;img/hello.gif&quot;</span><span class="o">,</span> <span class="s2">&quot;alt&quot;</span><span class="o">:</span> <span class="s2">&quot;alternative text&quot;</span><span class="o">)</span> <span class="cp">}}</span><span class="x"></span>
</pre></div>
</div>
</div>
<div class="section" id="stylesheets">
<h3>样式表（Stylesheets）<a class="headerlink" href="#stylesheets" title="永久链接至标题">¶</a></h3>
<div class="highlight-php"><div class="highlight"><pre><span class="cp">&lt;?php</span>

<span class="c1">// Generate &lt;link rel=&quot;stylesheet&quot; href=&quot;http://fonts.googleapis.com/css?family=Rosario&quot; type=&quot;text/css&quot;&gt;</span>
<span class="k">echo</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">stylesheetLink</span><span class="p">(</span><span class="s2">&quot;http://fonts.googleapis.com/css?family=Rosario&quot;</span><span class="p">,</span> <span class="k">false</span><span class="p">);</span>

<span class="c1">// Generate &lt;link rel=&quot;stylesheet&quot; href=&quot;/your-app/css/styles.css&quot; type=&quot;text/css&quot;&gt;</span>
<span class="k">echo</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">stylesheetLink</span><span class="p">(</span><span class="s2">&quot;css/styles.css&quot;</span><span class="p">);</span>
</pre></div>
</div>
<p>Volt 语法:</p>
<div class="highlight-jinja"><div class="highlight"><pre><span class="c">{# Generate &lt;link rel=&quot;stylesheet&quot; href=&quot;http://fonts.googleapis.com/css?family=Rosario&quot; type=&quot;text/css&quot;&gt; #}</span><span class="x"></span>
<span class="cp">{{</span> <span class="nv">stylesheet_link</span><span class="o">(</span><span class="s2">&quot;http://fonts.googleapis.com/css?family=Rosario&quot;</span><span class="o">,</span> <span class="kp">false</span><span class="o">)</span> <span class="cp">}}</span><span class="x"></span>

<span class="c">{# Generate &lt;link rel=&quot;stylesheet&quot; href=&quot;/your-app/css/styles.css&quot; type=&quot;text/css&quot;&gt; #}</span><span class="x"></span>
<span class="cp">{{</span> <span class="nv">stylesheet_link</span><span class="o">(</span><span class="s2">&quot;css/styles.css&quot;</span><span class="o">)</span> <span class="cp">}}</span><span class="x"></span>
</pre></div>
</div>
</div>
<div class="section" id="javascript">
<h3>脚本（Javascript）<a class="headerlink" href="#javascript" title="永久链接至标题">¶</a></h3>
<div class="highlight-php"><div class="highlight"><pre><span class="cp">&lt;?php</span>

<span class="c1">// Generate &lt;script src=&quot;http://localhost/javascript/jquery.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</span>
<span class="k">echo</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">javascriptInclude</span><span class="p">(</span><span class="s2">&quot;http://localhost/javascript/jquery.min.js&quot;</span><span class="p">,</span> <span class="k">false</span><span class="p">);</span>

<span class="c1">// Generate &lt;script src=&quot;/your-app/javascript/jquery.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</span>
<span class="k">echo</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">javascriptInclude</span><span class="p">(</span><span class="s2">&quot;javascript/jquery.min.js&quot;</span><span class="p">);</span>
</pre></div>
</div>
<p>Volt 语法：</p>
<div class="highlight-jinja"><div class="highlight"><pre><span class="c">{# Generate &lt;script src=&quot;http://localhost/javascript/jquery.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt; #}</span><span class="x"></span>
<span class="cp">{{</span> <span class="nv">javascript_include</span><span class="o">(</span><span class="s2">&quot;http://localhost/javascript/jquery.min.js&quot;</span><span class="o">,</span> <span class="kp">false</span><span class="o">)</span> <span class="cp">}}</span><span class="x"></span>

<span class="c">{# Generate &lt;script src=&quot;/your-app/javascript/jquery.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt; #}</span><span class="x"></span>
<span class="cp">{{</span> <span class="nv">javascript_include</span><span class="o">(</span><span class="s2">&quot;javascript/jquery.min.js&quot;</span><span class="o">)</span> <span class="cp">}}</span><span class="x"></span>
</pre></div>
</div>
</div>
<div class="section" id="html5-html5-elements-generic-html-helper">
<h3>HTML5 对象（HTML5 elements - generic HTML helper）<a class="headerlink" href="#html5-html5-elements-generic-html-helper" title="永久链接至标题">¶</a></h3>
<p>Phalcon 提供了一个通用的方法去生成任何HTML的元素。在这个方法中，需要开发者将有效的HTML元素标签传给此方法。</p>
<div class="highlight-php"><div class="highlight"><pre><span class="cp">&lt;?php</span>

<span class="c1">// Generate</span>
<span class="c1">// &lt;canvas id=&quot;canvas1&quot; width=&quot;300&quot; class=&quot;cnvclass&quot;&gt;</span>
<span class="c1">// This is my canvas</span>
<span class="c1">// &lt;/canvas&gt;</span>
<span class="k">echo</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">tagHtml</span><span class="p">(</span><span class="s2">&quot;canvas&quot;</span><span class="p">,</span> <span class="p">[</span><span class="s2">&quot;id&quot;</span> <span class="o">=&gt;</span> <span class="s2">&quot;canvas1&quot;</span><span class="p">,</span> <span class="s2">&quot;width&quot;</span> <span class="o">=&gt;</span> <span class="s2">&quot;300&quot;</span><span class="p">,</span> <span class="s2">&quot;class&quot;</span> <span class="o">=&gt;</span> <span class="s2">&quot;cnvclass&quot;</span><span class="p">],</span> <span class="k">false</span><span class="p">,</span> <span class="k">true</span><span class="p">,</span> <span class="k">true</span><span class="p">);</span>
<span class="k">echo</span> <span class="s2">&quot;This is my canvas&quot;</span><span class="p">;</span>
<span class="k">echo</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">tagHtmlClose</span><span class="p">(</span><span class="s2">&quot;canvas&quot;</span><span class="p">);</span>
</pre></div>
</div>
<p>Volt 语法：</p>
<div class="highlight-html+jinja"><div class="highlight"><pre>{# Generate
&lt;canvas id=&quot;canvas1&quot; width=&quot;300&quot; class=&quot;cnvclass&quot;&gt;
This is my canvas
&lt;/canvas&gt; #}
{{ tag_html(&quot;canvas&quot;, [&quot;id&quot;: &quot;canvas1&quot;, width&quot;: &quot;300&quot;, &quot;class&quot;: &quot;cnvclass&quot;], false, true, true) }}
    This is my canvas
{{ tag_html_close(&quot;canvas&quot;) }}
</pre></div>
</div>
</div>
</div>
<div class="section" id="tag-service">
<h2>标签服务（Tag Service）<a class="headerlink" href="#tag-service" title="永久链接至标题">¶</a></h2>
<p><a class="reference internal" href="../api/Phalcon_Tag.html"><em>Phalcon\Tag</em></a> 类可以通过 &#8216;tag&#8217; 服务来使用，这意味着你可以在服务容器被加载的任何地方访问到它。</p>
<div class="highlight-php"><div class="highlight"><pre><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tag</span><span class="o">-&gt;</span><span class="na">linkTo</span><span class="p">(</span><span class="s2">&quot;pages/about&quot;</span><span class="p">,</span> <span class="s2">&quot;About&quot;</span><span class="p">)</span> <span class="cp">?&gt;</span><span class="x"></span>
</pre></div>
</div>
<p>在服务容器中我们可以很容易的添加一个新的组件去替换&#8217;tag&#8217;组件。</p>
<div class="highlight-php"><div class="highlight"><pre><span class="cp">&lt;?php</span>

<span class="k">use</span> <span class="nx">Phalcon\Tag</span><span class="p">;</span>

<span class="k">class</span> <span class="nc">MyTags</span> <span class="k">extends</span> <span class="nx">Tag</span>
<span class="p">{</span>
    <span class="c1">// ...</span>

    <span class="c1">// Create a new helper</span>
    <span class="k">public</span> <span class="k">static</span> <span class="k">function</span> <span class="nf">myAmazingHelper</span><span class="p">(</span><span class="nv">$parameters</span><span class="p">)</span>
    <span class="p">{</span>
        <span class="c1">// ...</span>
    <span class="p">}</span>

    <span class="c1">// Override an existing method</span>
    <span class="k">public</span> <span class="k">static</span> <span class="k">function</span> <span class="nf">textField</span><span class="p">(</span><span class="nv">$parameters</span><span class="p">)</span>
    <span class="p">{</span>
        <span class="c1">// ...</span>
    <span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<p>然后改变&#8217;tag&#8217;标签的定义：</p>
<div class="highlight-php"><div class="highlight"><pre><span class="cp">&lt;?php</span>

<span class="nv">$di</span><span class="p">[</span><span class="s2">&quot;tag&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="k">function</span> <span class="p">()</span> <span class="p">{</span>
    <span class="k">return</span> <span class="k">new</span> <span class="nx">MyTags</span><span class="p">();</span>
<span class="p">};</span>
</pre></div>
</div>
</div>
<div class="section" id="creating-your-own-helpers">
<h2>创建助手（Creating your own helpers）<a class="headerlink" href="#creating-your-own-helpers" title="永久链接至标题">¶</a></h2>
<p>你可以简单地创建你自己的方法。首先，在你的控制器和模型的同级目录下创建一个新的文件夹，给此文件夹起一个和它功能相关的名字。在这里，叫它&#8221;customhelpers&#8221;好了。接下来我们在此文件夹下创建一个新的文件命名为 <code class="docutils literal"><span class="pre">MyTags.php</span></code> 这时，我们有一个类似于 <code class="docutils literal"><span class="pre">/app/customhelpers/MyTags.php</span></code> 的结构，我们将扩展(extend)  <a class="reference internal" href="../api/Phalcon_Tag.html"><em>Phalcon\Tag</em></a> 并且实现(implement)这个类。下面是一个自定义的助手(helper)类：</p>
<div class="highlight-php"><div class="highlight"><pre><span class="cp">&lt;?php</span>

<span class="k">use</span> <span class="nx">Phalcon\Tag</span><span class="p">;</span>

<span class="k">class</span> <span class="nc">MyTags</span> <span class="k">extends</span> <span class="nx">Tag</span>
<span class="p">{</span>
    <span class="sd">/**</span>
<span class="sd">     * Generates a widget to show a HTML5 audio tag</span>
<span class="sd">     *</span>
<span class="sd">     * @param array</span>
<span class="sd">     * @return string</span>
<span class="sd">     */</span>
    <span class="k">public</span> <span class="k">static</span> <span class="k">function</span> <span class="nf">audioField</span><span class="p">(</span><span class="nv">$parameters</span><span class="p">)</span>
    <span class="p">{</span>
        <span class="c1">// Converting parameters to array if it is not</span>
        <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nb">is_array</span><span class="p">(</span><span class="nv">$parameters</span><span class="p">))</span> <span class="p">{</span>
            <span class="nv">$parameters</span> <span class="o">=</span> <span class="p">[</span><span class="nv">$parameters</span><span class="p">];</span>
        <span class="p">}</span>

        <span class="c1">// Determining attributes &quot;id&quot; and &quot;name&quot;</span>
        <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">]))</span> <span class="p">{</span>
            <span class="nv">$parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="nv">$parameters</span><span class="p">[</span><span class="s2">&quot;id&quot;</span><span class="p">];</span>
        <span class="p">}</span>

        <span class="nv">$id</span> <span class="o">=</span> <span class="nv">$parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span>

        <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$parameters</span><span class="p">[</span><span class="s2">&quot;name&quot;</span><span class="p">]))</span> <span class="p">{</span>
            <span class="nv">$parameters</span><span class="p">[</span><span class="s2">&quot;name&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="nv">$id</span><span class="p">;</span>
        <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
            <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nv">$parameters</span><span class="p">[</span><span class="s2">&quot;name&quot;</span><span class="p">])</span> <span class="p">{</span>
                <span class="nv">$parameters</span><span class="p">[</span><span class="s2">&quot;name&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="nv">$id</span><span class="p">;</span>
            <span class="p">}</span>
        <span class="p">}</span>

        <span class="c1">// Determining widget value,</span>
        <span class="c1">// \Phalcon\Tag::setDefault() allows to set the widget value</span>
        <span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$parameters</span><span class="p">[</span><span class="s2">&quot;value&quot;</span><span class="p">]))</span> <span class="p">{</span>
            <span class="nv">$value</span> <span class="o">=</span> <span class="nv">$parameters</span><span class="p">[</span><span class="s2">&quot;value&quot;</span><span class="p">];</span>

            <span class="nb">unset</span><span class="p">(</span><span class="nv">$parameters</span><span class="p">[</span><span class="s2">&quot;value&quot;</span><span class="p">]);</span>
        <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
            <span class="nv">$value</span> <span class="o">=</span> <span class="nx">self</span><span class="o">::</span><span class="na">getValue</span><span class="p">(</span><span class="nv">$id</span><span class="p">);</span>
        <span class="p">}</span>

        <span class="c1">// Generate the tag code</span>
        <span class="nv">$code</span> <span class="o">=</span> <span class="s1">&#39;&lt;audio id=&quot;&#39;</span> <span class="o">.</span> <span class="nv">$id</span> <span class="o">.</span> <span class="s1">&#39;&quot; value=&quot;&#39;</span> <span class="o">.</span> <span class="nv">$value</span> <span class="o">.</span> <span class="s1">&#39;&quot; &#39;</span><span class="p">;</span>

        <span class="k">foreach</span> <span class="p">(</span><span class="nv">$parameters</span> <span class="k">as</span> <span class="nv">$key</span> <span class="o">=&gt;</span> <span class="nv">$attributeValue</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nb">is_integer</span><span class="p">(</span><span class="nv">$key</span><span class="p">))</span> <span class="p">{</span>
                <span class="nv">$code</span><span class="o">.=</span> <span class="nv">$key</span> <span class="o">.</span> <span class="s1">&#39;=&quot;&#39;</span> <span class="o">.</span> <span class="nv">$attributeValue</span> <span class="o">.</span> <span class="s1">&#39;&quot; &#39;</span><span class="p">;</span>
            <span class="p">}</span>
        <span class="p">}</span>

        <span class="nv">$code</span><span class="o">.=</span><span class="s2">&quot; /&gt;&quot;</span><span class="p">;</span>

        <span class="k">return</span> <span class="nv">$code</span><span class="p">;</span>
    <span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<p>在我们创建了自定义的助手(helper)类之后，我们要在我们的public目录下的&#8221;index.php&#8221;中自动加载那个包含我们自定义助手类的目录。</p>
<div class="highlight-php"><div class="highlight"><pre><span class="cp">&lt;?php</span>

<span class="k">use</span> <span class="nx">Phalcon\Loader</span><span class="p">;</span>
<span class="k">use</span> <span class="nx">Phalcon\Mvc\Application</span><span class="p">;</span>
<span class="k">use</span> <span class="nx">Phalcon\Di\FactoryDefault</span><span class="p">();</span>
<span class="k">use</span> <span class="nx">Phalcon\Exception</span> <span class="k">as</span> <span class="nx">PhalconException</span><span class="p">;</span>

<span class="k">try</span> <span class="p">{</span>
    <span class="nv">$loader</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Loader</span><span class="p">();</span>

    <span class="nv">$loader</span><span class="o">-&gt;</span><span class="na">registerDirs</span><span class="p">(</span>
        <span class="p">[</span>
            <span class="s2">&quot;../app/controllers&quot;</span><span class="p">,</span>
            <span class="s2">&quot;../app/models&quot;</span><span class="p">,</span>
            <span class="s2">&quot;../app/customhelpers&quot;</span><span class="p">,</span> <span class="c1">// Add the new helpers folder</span>
        <span class="p">]</span>
    <span class="p">);</span>

    <span class="nv">$loader</span><span class="o">-&gt;</span><span class="na">register</span><span class="p">();</span>

    <span class="nv">$di</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">FactoryDefault</span><span class="p">();</span>

    <span class="c1">// Assign our new tag a definition so we can call it</span>
    <span class="nv">$di</span><span class="o">-&gt;</span><span class="na">set</span><span class="p">(</span>
        <span class="s2">&quot;MyTags&quot;</span><span class="p">,</span>
        <span class="k">function</span> <span class="p">()</span> <span class="p">{</span>
            <span class="k">return</span> <span class="k">new</span> <span class="nx">MyTags</span><span class="p">();</span>
        <span class="p">}</span>
    <span class="p">);</span>

    <span class="nv">$application</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Application</span><span class="p">(</span><span class="nv">$di</span><span class="p">);</span>

    <span class="nv">$response</span> <span class="o">=</span> <span class="nv">$application</span><span class="o">-&gt;</span><span class="na">handle</span><span class="p">();</span>

    <span class="nv">$response</span><span class="o">-&gt;</span><span class="na">send</span><span class="p">();</span>
<span class="p">}</span> <span class="k">catch</span> <span class="p">(</span><span class="nx">PhalconException</span> <span class="nv">$e</span><span class="p">)</span> <span class="p">{</span>
    <span class="k">echo</span> <span class="s2">&quot;PhalconException: &quot;</span><span class="p">,</span> <span class="nv">$e</span><span class="o">-&gt;</span><span class="na">getMessage</span><span class="p">();</span>
<span class="p">}</span>
</pre></div>
</div>
<p>现在，你就可以在你的视图中使用你的新助手类了。</p>
<div class="highlight-php"><div class="highlight"><pre><span class="x">&lt;body&gt;</span>

<span class="x">    </span><span class="cp">&lt;?php</span>

    <span class="k">echo</span> <span class="nx">MyTags</span><span class="o">::</span><span class="na">audioField</span><span class="p">(</span>
        <span class="p">[</span>
            <span class="s2">&quot;name&quot;</span> <span class="o">=&gt;</span> <span class="s2">&quot;test&quot;</span><span class="p">,</span>
            <span class="s2">&quot;id&quot;</span>   <span class="o">=&gt;</span> <span class="s2">&quot;audio_test&quot;</span><span class="p">,</span>
            <span class="s2">&quot;src&quot;</span>  <span class="o">=&gt;</span> <span class="s2">&quot;/path/to/audio.mp3&quot;</span><span class="p">,</span>
        <span class="p">]</span>
    <span class="p">);</span>

    <span class="cp">?&gt;</span><span class="x"></span>

<span class="x">&lt;/body&gt;</span>
</pre></div>
</div>
<p>在下一节中，我们将讨论关于 <a class="reference internal" href="volt.html"><em>Volt</em></a> 的内容，它是PHP的一个速度很快的模板引擎，在 <a class="reference internal" href="../api/Phalcon_Tag.html"><em>Phalcon\Tag</em></a> 中你将得到更多关于视图助手的友好的提示。</p>
</div>
</div>


                    </div>
                  </div>
                </div>
            </div>
          </td>
        </tr>
      </table>
    <div class="related">
      <ul>
        <li class="right" >
          <a href="../genindex.html" title="总目录"
             >索引</a></li>
        <li class="right" >
          <a href="assets.html" title="资源文件管理（Assets Management）"
             >下一页</a> |</li>
        <li class="right" >
          <a href="views.html" title="使用视图（Using Views）"
             >上一页</a> |</li> 
      </ul>
    </div>

      <div class="prefooter">
  <div class="container">
      <div class="row">
          <div class="col-sm-3 text-right">
              <span>Follow along:</span>
          </div>
          <div class="col-sm-6 text-center">
              <a href="https://twitter.com/phalconphp" alt="Twitter" class="btn-social btn-social-twitter"><i class="icon-twitter"></i></a>
              <a href="https://www.facebook.com/pages/Phalcon-Framework/134230726685897" alt="Facebook" class="btn-social btn-social-facebook"><i class="icon-facebook"></i></a>
              <a href="https://plus.google.com/102376109340560896457" alt="Google+" class="btn-social btn-social-googleplus"><i class="icon-googleplus"></i></a>
              <a href="https://github.com/phalcon/cphalcon" alt="Github" class="btn-social btn-social-github"><i class="icon-github"></i></a>
          </div>
          <div class="col-sm-3">
          </div>
      </div>
  </div>

</div>
<footer class="footer">
    <div class="container">
        <div class="row">
            <div class="col-xs-4 col-sm-3">
                <h4>Download</h4>
                <ul>
                    <li><a href="/download">Installing Phalcon PHP</a></li>
                    <li><a href="http://docs.phalconphp.com/en/latest/index.html" class="header-nav-link" target="_blank">Documentation</a></li>
                    <li><a href="http://api.phalconphp.com">API</a></li>
                    <li><a href="http://docs.phalconphp.com/en/latest/reference/tutorial.html">Tutorial</a></li>
                    <li><a href="http://docs.phalconphp.com/en/latest/reference/tutorial.html#sample-applications">Sample Applications</a></li>
                </ul>
            </div>
            <div class="col-xs-4 col-sm-3">
                <h4>Community</h4>
                <ul>
                    <li><a href="http://forum.phalconphp.com/" class="header-nav-link" target="_blank">Forum</a></li>
                    <li><a href="https://github.com/phalcon/cphalcon">GitHub</a></li>
                    <li><a href="https://github.com/phalcon/cphalcon/issues">Issue Tracker</a></li>
                    <li><a href="http://stackoverflow.com/questions/tagged/phalcon">Stack Overflow</a></li>
                    <li><a href="/en/testimonials">Testimonials</a></li>
                    <li><a href="http://builtwith.phalconphp.com/">Built with Phalcon</a></li>
                    <li><a href="http://store.phalconphp.com/">Store</a></li>
                </ul>
            </div>
            <div class="col-xs-4 col-sm-2">
                <h4>About</h4>
                <ul>
                    <li><a class="link-black" href="http://blog.phalconphp.com/">Blog</a></li>
                    <li><a href="/en/about">About</a></li>
                    <li><a href="/en/team">Team</a></li>
                    <li><a href="/en/roadmap">Roadmap</a></li>
                    <li><a href="/en/donate">Donate</a></li>
                    <li><a href="/en/consulting">Consulting</a></li>
                    <li><a href="/en/hosting">Hosting</a></li>
                </ul>
            </div>
            <div id="license-spaccer" class="visible-xs"></div>
            <div id="license-wrapper" class="col-xs-12 col-sm-4">
                <p class="license">
                    Phalcon is an open-source PHP framework <br>built as a C-extension. It is available under the <br>
                    <a href="http://opensource.org/licenses/BSD-3-Clause" target="_blank">new BSD License</a>.
                    <br>
                    <br>
                    Except where otherwise noted, content on this site is licensed under the
                    <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0 License.</a>
                </p>
            </div>
        </div>
    </div>
</footer>

    </div>
    <script type="text/javascript">
    $(window).on("load", function(){
      var cx = '009733439235723428699:lh9ltjgvdz8';
      var gcse = document.createElement('script');
      gcse.type = 'text/javascript';
      gcse.async = true;
      gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//www.google.com/cse/cse.js?cx=' + cx;
      var s = document.getElementsByTagName('script')[0];
      s.parentNode.insertBefore(gcse, s);
    });
    </script>

  </body>
</html>